package com.stxx.framwork.utils;

import java.math.BigDecimal;

public class ObjectUtils {
    public static <T> T get(Object value, Class<T> clazz) {
        if(value==null)return null;
        if (value.getClass() == clazz) {
            return (T)value;
        }
        if(Integer.class==clazz){
            return (T)(Integer.valueOf(value.toString()));
        }else if(Double.class==clazz){
            return (T)(Double.valueOf(value.toString()));
        }else if(Float.class==clazz){
            return (T)(Float.valueOf(value.toString()));
        }else if(Boolean.class==clazz){
            return (T)(Boolean.valueOf(value.toString()));
        }else if(Long.class==clazz){
            return (T)(Long.valueOf(value.toString()));
        }else if(BigDecimal.class == clazz){
            return (T)(new BigDecimal(value.toString()));
        }else if(Short.class==clazz){
            return (T)(Short.valueOf(value.toString()));
        }else if(Byte.class==clazz){
            return (T)(Byte.valueOf(value.toString()));
        }else{
            return (T)(value.toString());
        }
    }

    public static boolean equals(Object obj1,Object obj2) {
        if(obj1==null)return obj2 == null;
        return obj1.equals(obj2);
    }
}
